package cn.testfan.util;

import java.nio.charset.Charset;

import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;

public class HashingUtil {

	public static void main(String[] args) {
		System.out.println(md5("aaa"));
		System.out.println(sha1("aaa"));
	}

	public static String md5(String value) {

		Hasher hasher = Hashing.md5().newHasher();
		hasher.putString(value, Charset.forName("UTF-8"));
		return hasher.hash().toString();
	}

	public static String sha1(String value) {

		Hasher hasher = Hashing.sha1().newHasher();
		hasher.putString(value, Charset.forName("UTF-8"));
		return hasher.hash().toString();
	}
}
